package core {
	/**
	 * ...
	 * @author Zszen
	 */
	public class DateFormat {
		/**
		 * 范围文字格式化时间
		 * @param	dataStr "2011-6-12 中国标准时间上午12时10分07秒"
		 * @return
		 */
		public static function format(dataStr:String):Date {
			var data:Array = dataStr.split(" ")
			var dataDate:Array = data[0].split("-")
			var dataTime:Array = []
			var dataTimeStr:String = data[1].substr(data[1].indexOf("午")-1)
			dataTime.push(dataTimeStr.split("时")[0])
			dataTime.push(dataTimeStr.split("时")[1].split("分")[0])
			dataTime.push(dataTimeStr.split("时")[1].split("分")[1].split("秒")[0])
			if (dataTime[0].indexOf("上午") != -1) {
				dataTime[0] = dataTime[0].split("上午")[1]
			}else {
				dataTime[0] = Number(parseInt(dataTime[0].split("下午")[1]) + 12).toString()
			}
			for (var i:int = 0; i < dataDate.length; i++) {
				dataDate[i] = parseInt(dataDate[i])
			}
			for (i = 0; i < dataTime.length; i++) {
				dataTime[i] = parseInt(dataTime[i])
			}
			var date:Date = new Date(dataDate[0],dataDate[1]-1,dataDate[2],dataTime[0],dataTime[1],dataTime[2])
			return date
		}
		/**
		 * 返回毫秒差
		 * @param	newDate
		 * @param	oldDate
		 * @return
		 */
		public static function timeDuring(newDate:Date, oldDate:Date):uint {
			return newDate.getTime()-oldDate.getTime()
		}
	}

}